package com.itheima.test.Demo9;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

/*
properties的使用
 */
public class Demo9 {
    public static void main(String[] args) throws IOException {
        //把集合中的数据保存到文件
        myStore();
        //把文件中的数据加载到集合
        MyLoad();
    }

    private static void myStore() throws IOException {
        Properties prop = new Properties();
        prop.setProperty("itheima001","佟丽娅");
        prop.setProperty("itheima002","赵丽颖");
        prop.setProperty("itheima003","刘诗诗");
        FileWriter fw = new FileWriter("day13_字符流\\e.txt");
        prop.store(fw,null);
        fw.close();
    }

    private static void MyLoad() throws IOException {
        //创建对象
        Properties prop= new Properties();
        FileReader fr = new FileReader("day13_字符流\\e.txt");
        prop.load(fr);
        fr.close();
        System.out.println(prop);
    }
}
